package com.sgb.contract.api;

import com.sgb.contract.model.ContractApprovalReBean;
import com.sgb.contract.model.ContractApprovalStatusBean;
import com.sgb.contract.model.ContractCategoryBean;
import com.sgb.contract.model.ContractDetailBean;
import com.sgb.contract.model.ContractKeyValueBean;
import com.sgb.contract.model.ContractListSearchBean;
import com.sgb.contract.model.ContractOperationLogBean;
import com.sgb.contract.model.ContractUserMsgBean;
import com.sgb.contract.model.UpdateBean;
import com.sgb.contract.test.model.OpenAccountDetailEntity;
import com.sgb.contract.test.model.OpenAccountEntity;
import com.swgk.core.base.model.entity.BaseEntity;

import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;

/**
 * 合同API
 *
 * @author cyj
 */
public interface ContractApi {

    /**
     * 合同列表搜索
     *
     * @param obj ContractListSearchBean
     * @return Call<BaseEntity < ContractListSearchBean>>
     */
    @POST("v1/contract/search")
    Call<BaseEntity<ContractListSearchBean>> contractListSearch(@Body Map<String, Object> obj);

    /**
     * 获取合同状态
     *
     * @return Call<BaseEntity < ContractListSearchBean>>
     */
    @GET("v1/contract/getStatus")
    Call<BaseEntity<List<ContractKeyValueBean>>> getContractStatus();

    /**
     * 获取合同分类
     *
     * @return Call<BaseEntity < ContractListSearchBean>>
     */
    @GET("v1/contract/getContractType")
    Call<BaseEntity<List<ContractKeyValueBean>>> getContractType();

    /**
     * 签署合同-状态校验
     *
     * @param no     合同编号
     * @param status 当前页面显示状态
     * @return
     */
    @POST("v1/contract/chenKSignContract")
    Call<BaseEntity<Boolean>> checkSignContract(@Query("no") String no, @Query("status") String status, @Query("signStatus") int signStatus, @Query("signCase") int signCase);

    /**
     * 校验合同状态
     *
     * @param no     合同编号
     * @param status 当前页面显示状态
     * @return
     */
    @POST("v1/contract/checkStatusByNowStatus")
    Call<BaseEntity<Boolean>> checkStatusByNowStatus(@Query("no") String no, @Query("status") String status, @Query("signStatus") int signStatus, @Query("signCase") int signCase, @Query("auditStatus") int auditStatus);



    /**
     * 发送合同
     *
     * @param map
     * @return
     */
    @POST("v1/contract/send")
    Call<BaseEntity<Object>> sendContract(@Body Map<String, Object> map);

    /**
     * 退回合同
     *
     * @param map
     * @return
     */
    @POST("v1/contract/discard")
    Call<BaseEntity<Object>> discardContract(@Body Map<String, Object> map);

    /**
     * 签署合同
     *
     * @param map
     * @return
     */
    @POST("v1/contract/submitSign")
    Call<BaseEntity<Object>> signContract(@Body Map<String, Object> map);

    /**
     * 签署合同-获取安心签验证码
     *
     * @param contractNo
     * @return
     */
    @GET("v1/contract/sendCode")
    Call<BaseEntity<Object>> getSignContractCode(@Query("contractNo") String contractNo);

    /**
     * 修改合同
     *
     * @param map
     * @return
     */
    @POST("v1/contract/reject")
    Call<BaseEntity<Object>> rejectContract(@Body Map<String, Object> map);

    /**
     * 获取合同详情
     *
     * @param contractId
     * @return
     */
    @GET("v1/contract/detail/{contractId}")
    Call<BaseEntity<ContractDetailBean>> getContractDetail(@Path("contractId") String contractId);

    /**
     * 获取合同操作日志
     *
     * @param contractNo
     * @return
     */
    @GET("v1/contractLog/list/{contractNo}")
    Call<BaseEntity<List<ContractOperationLogBean>>> getContractLog(@Path("contractNo") String contractNo);

    /**
     * 开户详情
     *
     * @return
     */
    @GET("v1/account/detail")
    Call<BaseEntity<OpenAccountDetailEntity>> getCompanyDetail();

    /**
     * 开户详情
     *
     * @param tel
     * @return
     */
    @GET("v1/account/getValidateCode")
    Call<BaseEntity<Object>> getValidateCode(@Query("tel") String tel, @Query("isUpdate") boolean isUpdate);

    /**
     * 电子合同账户-修改账户信息
     *
     * @param map
     * @return
     */
    @POST("v1/account/updateAccount")
    Call<BaseEntity<Object>> updateAccount(@Body Map<String, Object> map);

    /**
     * 电子合同账户-开户
     *
     * @param body
     * @return
     */
    @POST("v1/account/openAccount")
    Call<BaseEntity<Object>> openAccount(@Body OpenAccountEntity body);

    /**
     * 合同分类
     *
     * @return
     */
    @POST("v1/contract/category")
    Call<BaseEntity<List<ContractCategoryBean>>> contractCategory();

    /**
     * 判断当前合同是否开启审批
     *
     * @param auditType 审批类型：发送审批 sendContract 签署审批 signContract
     * @return
     */
    @GET("v1/contract/checkOpenAudit")
    Call<BaseEntity<Boolean>> checkOpenAudit(@Query("auditType") String auditType);


    /**
     * 查询合同的审批状态
     *
     * @param id   合同id
     * @param type 审批类型：发送审批 sendContract 签署审批 signContract
     * @return
     */
    @GET("v1/contract/findAuditStatus")
    Call<BaseEntity<ContractApprovalStatusBean>> findAuditStatus(@Query("id") long id, @Query("type") String type);

    /**
     * 发起审批申请
     *
     * @param body
     * @return
     */
    @POST("v1/contract/contractApproval")
    Call<BaseEntity<Object>> contractApproval(@Body ContractApprovalReBean body);


    /**
     * 登陆后获取用户信息（包含个人及企业的认证状态）
     *
     * @return
     */
    @GET("logistics/freight/account/getCurrentUserInfo")
    Call<BaseEntity<ContractUserMsgBean>> getUserInfo();

    /**
     * 根据合同编号获取合同修改日志
     *
     * @return
     */
    @GET("v1/contract/findByContractNo")
    Call<BaseEntity<List<UpdateBean>>> findByContractNo(@Query("contractNo") String contractNo);

    /**
     * 个人开户
     *
     * @return
     */
    @POST("v1/account/personOpenAccount")
    Call<BaseEntity<Object>> personOpenAccount(@Body Map<String, Object> map);

    /**
     * 电子合同账户-修改账户信息
     *
     * @return
     */
    @POST("v1/account/updatePersonAccount")
    Call<BaseEntity<Object>> updatePersonAccount(@Body Map<String, Object> map);
}
